var u = Object.defineProperty;
var m = (r, t, s) =>
  t in r
    ? u(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s })
    : (r[t] = s);
var l = (r, t, s) => (m(r, typeof t != 'symbol' ? t + '' : t, s), s);
class g extends Error {
  constructor(s, e, a, o) {
    super();
    l(this, 'name');
    l(this, 'code');
    l(this, 'message');
    l(this, 'pos');
    l(this, 'linePos');
    (this.name = s), (this.code = a), (this.message = o), (this.pos = e);
  }
}
class f extends g {
  constructor(t, s, e) {
    super('YAMLParseError', t, s, e);
  }
}
class M extends g {
  constructor(t, s, e) {
    super('YAMLWarning', t, s, e);
  }
}
const P = (r, t) => s => {
  if (s.pos[0] === -1) return;
  s.linePos = s.pos.map(i => t.linePos(i));
  const { line: e, col: a } = s.linePos[0];
  s.message += ` at line ${e}, column ${a}`;
  let o = a - 1,
    n = r
      .substring(t.lineStarts[e - 1], t.lineStarts[e])
      .replace(/[\n\r]+$/, '');
  if (o >= 60 && n.length > 80) {
    const i = Math.min(o - 39, n.length - 79);
    (n = '…' + n.substring(i)), (o -= i - 1);
  }
  if (
    (n.length > 80 && (n = n.substring(0, 79) + '…'),
    e > 1 && /^ *$/.test(n.substring(0, o)))
  ) {
    let i = r.substring(t.lineStarts[e - 2], t.lineStarts[e - 1]);
    i.length > 80 &&
      (i =
        i.substring(0, 79) +
        `…
`),
      (n = i + n);
  }
  if (/[^ ]/.test(n)) {
    let i = 1;
    const c = s.linePos[1];
    c &&
      c.line === e &&
      c.col > a &&
      (i = Math.max(1, Math.min(c.col - a, 80 - o)));
    const p = ' '.repeat(o) + '^'.repeat(i);
    s.message += `:

${n}
${p}
`;
  }
};
export {
  g as YAMLError,
  f as YAMLParseError,
  M as YAMLWarning,
  P as prettifyError,
};
